package controller;

import com.jfinal.core.Controller;
import com.jfinal.core.Path;
import com.jfinal.plugin.activerecord.Page;
import model.StationVoltageInfo;
import service.StationService;


@Path("/stationInfo")
public class StationController extends Controller {

    private StationService stationService = new StationService();

    //条件分页查询
    public void searchStationInfo() {
        String zk_bdz_id = getPara("zk_bdz_id");
        String zk_bdz_name = getPara("zk_bdz_name");
        String line_name = getPara("line_name");
        //页数
        int pageNumber = getParaToInt("currentPage");
        //每页显示的条数
        int pageSize = getParaToInt("pageSize");
        Page<StationVoltageInfo> stationInfoPage = stationService.search(zk_bdz_id, zk_bdz_name, line_name, pageNumber, pageSize);
        renderJson(stationInfoPage);
    }

    //批量删除
    public void batchDelete() {
        String idsString = getPara("ids");
        String[] ids = idsString.split(",");
        stationService.batchDelete(ids);
        renderJson("success");
    }

    //添加
    public void saveStationInfo() {
        StationVoltageInfo stationInfo = getModel(StationVoltageInfo.class, "");
        stationService.save(stationInfo);
        renderJson("success");
    }

    //修改
    public void updateStationInfo() {
        StationVoltageInfo stationInfo = getModel(StationVoltageInfo.class, "");
        stationService.update(stationInfo);
        renderJson("success");
    }

    //删除
    public void deleteStationInfo() {
        String id = getPara("Id");
        stationService.deleteById(id);
        renderJson("success");
    }
}
